﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dhsystem.Main;
using dhSystemBLL.orderData;
using baseSet.importExport;
using dhDataAcess.dataAcess;
using dhDataAcess.dataAcess.orderDataSetTableAdapters;
using dhDataAcess.baseBLL;
using System.Data.SqlClient;
using dhSystemBLL.produceBLL;
using FastReport;
using dhsystem.produceForm;
using dhsystem.produceForm.pdrk;
using baseSet.power;

namespace dhsystem.orderForm
{
    public partial class FrmorderMaster : Form
    {
        orderProduceListBLL orderProduceList = new orderProduceListBLL();
        orderMasterBLL orderMaster = new orderMasterBLL();
        orderDetailBLL orderDetail = new orderDetailBLL();
        orderDetailUpdateBLL orderDetailUpdate = new orderDetailUpdateBLL();
        string state;
        public FrmorderMaster()
        {
            InitializeComponent();
        }
        //打开窗口时显示列表数据
        private void FrmorderMaster_Load(object sender, EventArgs e)
        {
            getData();

        }
        //新增按钮，显示新增数据组件
        private void toolAdd_Click(object sender, EventArgs e)
        {
            state = "新增";
            FrmorderMasterAdd orderMasterAdd = new FrmorderMasterAdd(bindingSourorderMaster, state);
            orderMasterAdd.ShowDialog();
            orderMasterAdd.Owner = this;
        }
        //工具栏查询按钮，查询所有列表数据
        private void toolQuery_Click(object sender, EventArgs e)
        {
            FrmDataQuery query = new FrmDataQuery(moduleInfo.orderMaster );
            DialogResult result = query.ShowDialog();
            if (result == DialogResult.Yes)
            {
                dGridorderMaster.DataSource = query.rTable;
            }
        }
 


        //刷新按钮
        private void buttupdate_Click(object sender, EventArgs e)
        {
            getData();
            //dGridorderMaster.DataSource = orderMaster.getorderMasterAll();
            //DcolumnSet.colSet(moduleInfo.orderMaster, dGridorderMaster);
            //toolStripStatusLabel1.Text = "订单表数据总条数:" + dGridorderMaster.RowCount.ToString() + "条";
        }
        //工具栏退出按钮，退出窗口
        private void toolExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //datagridview订单表第一列显示行号
        private void dGridorderMaster_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
        {
            e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
        }
        //datagridview订单明细表第一列显示行号
        private void dGridorderDetail_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
        {
            e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
        }
        private void getData()
        {
            //orderMasterTableAdapter orderMasterAdapter = new orderMasterTableAdapter();
            //orderDetailTableAdapter orderDetailAdapter = new orderDetailTableAdapter();
            //orderDataSet order = new orderDataSet();
            //orderMasterAdapter.FillorderMasterALL (order .orderMaster  );
            //orderDetailAdapter.FillorderDetailALL (order .orderDetail  );
            //bindingSourorderMaster .DataSource  = order ;
            //bindingSourorderMaster.DataMember = "orderMaster";
            bindingSourorderMaster.DataSource = orderMaster.getorderMasterAll();
            dGridorderMaster.DataSource = bindingSourorderMaster;
            DcolumnSet.colSet(moduleInfo.orderMaster, dGridorderMaster);
            toolStripStatusLabel1.Text = "订单表数据总条数:" + dGridorderMaster.RowCount.ToString() + "条";
            this.KeyPreview = true;
            //bindingSourceorderDetail.DataSource = bindingSourorderMaster;

            //bindingSourceorderDetail.DataMember = "fk_orderDetail_orderNo";
            //dGridorderDetail.DataSource = bindingSourceorderDetail;
            //DcolumnSet.colSet(moduleInfo.orderDetail , dGridorderDetail );
            //toolStripStatusLabel3.Text = "订单明细表数据总条数:" + dGridorderDetail.RowCount.ToString() + "条";

            sysDataSet.modulAaccessDataTable modulAaccess = powerSet.modulPower(moduleInfo.orderMaster );
            foreach (sysDataSet.modulAaccessRow modulAaccessRow in modulAaccess)
            {
                buttonQuery.Enabled = modulAaccessRow.showAc;
                button15.Enabled = modulAaccessRow.showAc;
                button10.Enabled = modulAaccessRow.showAc;
                button11.Enabled = modulAaccessRow.showAc;
                toolStripButton35.Enabled = modulAaccessRow.addAc;
                toolStripButton23.Enabled = modulAaccessRow.editAc;
                toolStripButton16.Enabled = modulAaccessRow.editAc;
                toolStripButton14.Enabled = modulAaccessRow.editAc;
                toolStripButton38.Enabled = modulAaccessRow.editAc;
                toolStripButton15.Enabled = modulAaccessRow.delAc;
                toolStripButton19.Enabled = modulAaccessRow.delAc;
                toolStripButton18.Enabled = modulAaccessRow.exportAc;
                toolStripButton21.Enabled = modulAaccessRow.exportAc;
                toolStripButton26.Enabled = modulAaccessRow.exportAc;

            }
        }
        //菜单栏审核按钮
        private void toolStripcheck_Click(object sender, EventArgs e)
        {
          
            string orderNo = dGridorderMaster.Rows[dGridorderMaster.CurrentRow.Index].Cells[1].Value.ToString();
            Frmordercheck check = new Frmordercheck(bindingSourorderMaster ,orderNo );
            check.ShowDialog();
            //try
            //{
            //    if (basicSql.getOrderStatus(orderNo) == "审核")
            //    {
            //        MessageBox.Show("订单已审核，无需再次审核");
            //    }
            //    else
            //    {
            //        DialogResult result = MessageBox.Show("是否审核订单：" + orderNo + "！", "提示信息", MessageBoxButtons.YesNo);
            //        if (result == DialogResult.Yes)
            //        {
            //            basicSql.getorderStatusUpdate (orderNo);
            //            //bindingSourorderMaster.DataSource = orderMaster.getorderMasterAllByorderNo (orderNo );
            //            //dGridorderMaster.DataSource = bindingSourorderMaster;
            //            //DcolumnSet.colSet(moduleInfo.orderMaster, dGridorderMaster);
            //            //bindingSourceorderDetail.DataSource = orderDetail.getorderDetailByorderNo(orderNo);
            //            //dGridorderDetail.DataSource = bindingSourceorderDetail;
            //            //DcolumnSet.colSet(moduleInfo.orderDetail, dGridorderDetail);
                      
            //            MessageBox.Show("审核成功");
            //        }
            //        getData();
            //    }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message.ToString());
            //}

        }
     
        private void tabPage2_Click(object sender, EventArgs e)
        {
           
        }
        //通知单查询
        private void button11_Click(object sender, EventArgs e)
        {

            try
            {
              
                baseSet.Query q = new baseSet.Query(null, dhDataAcess.baseBLL.dataConn.connOpen());
                bindingSource1.DataSource = q.sqlQueryLikeAll(moduleInfo.orderMaster, textorderproduce.Text.ToString().Trim());
                dGridorderproduce.DataSource = bindingSource1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
        //订单数量变更表
        private void tabPage6_Click(object sender, EventArgs e)
        {
            
        }
        //订单变更数量查询
        private void button10_Click(object sender, EventArgs e)
        {
            try
            {
                baseSet.Query q = new baseSet.Query(null, dhDataAcess.baseBLL.dataConn.connOpen());
                bindingSourceorderDetailupdate.DataSource = q.sqlQueryLikeAll(moduleInfo.orderDetailUpdate, textorderDetailupdate.Text.ToString().Trim());
                dGridupdate.DataSource = bindingSourceorderDetailupdate;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
       


        private void button12_Click(object sender, EventArgs e)
        {
            try
            {
                baseSet.Query q = new baseSet.Query(null, dhDataAcess.baseBLL.dataConn.connOpen());
                bindingSourcequxiao.DataSource = q.sqlQueryLikeAll(moduleInfo.orderDetail, textquxiao.Text.ToString().Trim());
                dGridquxiao.DataSource = bindingSourcequxiao;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }


        //private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    bindingSourceorderProduceList.DataSource = orderProduceList.getorderProduceListAll();
        //    dGridorderproduce.DataSource = bindingSourceorderProduceList;
        //    DcolumnSet.colSet(moduleInfo.orderProduceList, dGridorderProduceList);
        //    toolStripStatusLabel1.Text = "数据总条数:" + dGridorderproduce.RowCount.ToString() + "条";
        //}

        private void tabControl1_Selected(object sender, TabControlEventArgs e)
        {
            //已审核订单
            if (e.TabPage == tabPage2)
            {
               
                bindingSource1.DataSource = orderMaster.getorderMasterAllByorderStatusNo  ("新建");
                dGridorderproduce.DataSource = bindingSource1;
                DcolumnSet.colSet(moduleInfo.orderMaster , dGridorderproduce);
                toolStripStatusLabel1.Text = "数据总条数:" + dGridorderproduce.RowCount.ToString() + "条";
            }
            //未审核订单
            if (e.TabPage == tabPage8)
            {
                bindingSource2.DataSource = orderMaster.getorderMasterAllByorderStatus ("新建");
                dGridNocheck.DataSource = bindingSource2;
                DcolumnSet.colSet(moduleInfo.orderMaster , dGridNocheck);
                toolStripStatusLabel1.Text = "数据总条数:" + dGridorderproduce.RowCount.ToString() + "条";
            }
            //订单明细数量变更
            if (e.TabPage == tabPage6)
            {
                bindingSourceorderDetailupdate.DataSource = orderDetailUpdate.getorderDetailUpdateAll();
                dGridupdate.DataSource = bindingSourceorderDetailupdate;
                DcolumnSet.colSet(moduleInfo.orderDetailUpdate, dGridupdate);
                toolStripStatusLabel1.Text = "数据总条数:" + dGridupdate.RowCount.ToString() + "条";
            }
            //取消明细变更
            if (e.TabPage == tabPage7)
            {
                bindingSourcequxiao.DataSource = orderDetail.getorderDetailAllBydetailStatus("取消");
                dGridquxiao.DataSource = bindingSourcequxiao;
                DcolumnSet.colSet(moduleInfo.orderDetail, dGridquxiao);
                toolStripStatusLabel1.Text = "数据总条数:" + dGridquxiao.RowCount.ToString() + "条";
            }
            //已复期订单
            if (e.TabPage == tabPage9)
            {
                bSourcefuqiYes.DataSource = orderMaster.getorderMasterAllByorderStatus("已复期");
                dGridfuqiYes.DataSource = bSourcefuqiYes;
                DcolumnSet.colSet(moduleInfo.orderMaster, dGridfuqiYes);
                toolStripStatusLabel1.Text = "数据总条数:" + dGridfuqiYes.RowCount.ToString() + "条";
            }
            //未复期订单
            if (e.TabPage == tabPage10)
            {
                bSourcefuqiNo.DataSource = orderMaster.getorderMasterAllByorderStatus ("审核");
                dGridfuqiNo.DataSource = bSourcefuqiNo;
                DcolumnSet.colSet(moduleInfo.orderMaster, dGridfuqiNo);
                toolStripStatusLabel1.Text = "数据总条数:" + dGridfuqiNo.RowCount.ToString() + "条";
            }
        }
       //查看订单
        private void 复制单元格ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string orderNo = dGridorderMaster.Rows[dGridorderMaster.CurrentRow.Index].Cells[1].Value.ToString();
            Frmordercheck check = new Frmordercheck(bindingSourorderMaster, orderNo);
            check.ShowDialog();
        }

        private void toolPrint_Click(object sender, EventArgs e)
        {

        }
        //打印生产通知单
        private void button13_Click(object sender, EventArgs e)
        {
            //List<string> list = new List<string>();
            //foreach (DataGridViewRow row in dGridorderproduce.SelectedRows)
            //{
            //    list.Add(row.Cells["orderDetailNo"].Value.ToString());
            //}
            //basicSql.getproduceNo(list);
            //Report r = new Report();
            //DataTable V_orderproduceTable = new DataTable();
            //V_orderproduceTable.Load(basicSql.getproduceNo(list));
            //DataSet ds = new DataSet();
            //ds.Tables.Add(V_orderproduceTable);
            //ds.Tables.Add(orderProduceList.getproduceByproduceNo(dGridorderProduceList.CurrentRow.Cells["produceNo"].Value.ToString()));
            //r.Load(@"e:\东华软件项目\报表\orderproduce.frx");
            //r.Load(@"\\192.168.0.27\东华软件\报表\orderproduce.frx");

            //r.RegisterData(ds);
            //r.Design();
        }

        private void 梳织打印ToolStripMenuItem_Click(object sender, EventArgs e)
        {
           
        }

        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            string orderNo = dGridorderproduce.CurrentRow.Cells["orderNo"].Value.ToString();
            //string ptype = dGridorderMaster.CurrentRow.Cells["ptype"].Value.ToString();
            Report r = new Report();
            DataSet ds = new DataSet();
            ds.Tables.Add(orderMaster.getorderproduceTableAllByptype(orderNo, "梳织"));
            //r.Load(@"E:\东华软件项目\报表\orderproduce.frx");
            r.Load(@"\\192.168.0.27\东华软件\报表\orderproduce.frx");

            r.RegisterData(ds);
          //  r.Design();
            r.Show();
        }

        private void button15_Click(object sender, EventArgs e)
        {
            try
            {
                baseSet.Query q = new baseSet.Query(null, dhDataAcess.baseBLL.dataConn.connOpen());
                bindingSource2.DataSource = q.sqlQueryLikeAll(moduleInfo.orderMaster, textqury.Text.ToString().Trim());
                dGridorderproduce.DataSource = bindingSource2;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        private void toolStripMenuItem4_Click(object sender, EventArgs e)
        {
            string orderNo = dGridNocheck.CurrentRow.Cells["orderNo"].Value.ToString();
            Frmordercheck check = new Frmordercheck(bindingSource2, orderNo);
            check.ShowDialog();
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {

            string orderNo = dGridorderproduce.CurrentRow.Cells["orderNo"].Value.ToString();
            Frmordercheck check = new Frmordercheck(bindingSource1, orderNo);
            check.ShowDialog();
        }

        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            string orderNo = dGridorderproduce.CurrentRow.Cells["orderNo"].Value.ToString();
            //string ptype = dGridorderMaster.CurrentRow.Cells["ptype"].Value.ToString();
            Report r = new Report();
            DataSet ds = new DataSet();
            ds.Tables.Add(orderMaster.getorderproduceTableAllByptype(orderNo, "针织"));
           // ds.Tables.Add(orderDetail.getorderDetailByorderptype(orderNo, "针织"));
            //r.Load(@"e:\东华软件项目\报表\orderproduce.frx");
            r.Load(@"\\192.168.0.27\东华软件\报表\orderproduce.frx");
            r.RegisterData(ds);
           // r.Design();
            r.Show();
        }
        //导出
        private void toolExport_Click(object sender, EventArgs e)
        {
            FrmExcelExport frm = new FrmExcelExport(moduleInfo.V_orderproduceTable , dGridorderproduce, "生产通知单单");
            frm.ShowDialog();
        }

        private void 生产复期ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string orderNo = dGridfuqiNo.CurrentRow.Cells["orderNo"].Value.ToString();
            FrmproductDate productDate = new FrmproductDate(orderNo);
            DialogResult result = productDate.ShowDialog();
            if (result == DialogResult.Yes)
            {
                bindingSourcequxiao.DataSource = orderDetail.getorderDetailAllBydetailStatus("审核");
                dGridquxiao.DataSource = bindingSourcequxiao;
                DcolumnSet.colSet(moduleInfo.orderDetail, dGridquxiao);
                toolStripStatusLabel1.Text = "数据总条数:" + dGridquxiao.RowCount.ToString() + "条";
            }
        }

        private void toolStripMenuItem8_Click(object sender, EventArgs e)
        {
            string orderNo = dGridfuqiYes.CurrentRow.Cells["orderNo"].Value.ToString();
            Frmordercheck check = new Frmordercheck(bSourcefuqiYes, orderNo);
            check.ShowDialog();
        }

        private void button13_Click_1(object sender, EventArgs e)
        {
            try
            {
                baseSet.Query q = new baseSet.Query(null, dhDataAcess.baseBLL.dataConn.connOpen());
                bSourcefuqiYes.DataSource = q.sqlQueryLikeAll(moduleInfo.orderMaster, textBox2.Text.ToString().Trim());
                dGridfuqiYes.DataSource = bindingSourorderMaster;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        private void button14_Click(object sender, EventArgs e)
        {
            try
            {
                baseSet.Query q = new baseSet.Query(null, dhDataAcess.baseBLL.dataConn.connOpen());
                bSourcefuqiNo.DataSource = q.sqlQueryLikeAll(moduleInfo.orderMaster, textBox3.Text.ToString().Trim());
                dGridfuqiNo.DataSource = bindingSourorderMaster;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        private void toolSave_Click(object sender, EventArgs e)
        {

        }
        //订单选项卡编辑
        private void toolStripButton14_Click(object sender, EventArgs e)
        {
            state = "编辑";
            FrmorderMasterAdd orderMasterAdd = new FrmorderMasterAdd(bindingSourorderMaster, state);
            orderMasterAdd.ShowDialog();
        }
        //订单选项卡删除
        private void toolStripButton15_Click(object sender, EventArgs e)
        {
            string orderNo = dGridorderMaster.Rows[dGridorderMaster.CurrentRow.Index].Cells[1].Value.ToString();
            try
            {

                if (basicSql.getOrderStatus(orderNo) != "新建")
                {
                    MessageBox.Show("订单已审核，不能删除");
                }
                else
                {
                    DialogResult result = MessageBox.Show("是否删除：" + orderNo + "！", "提示信息", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {

                        bindingSourorderMaster.DataSource = orderMaster.orderMasterDel(orderNo);

                    }
                    getData();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
        //订单选项卡查询
        private void toolStripButton17_Click(object sender, EventArgs e)
        {
            FrmDataQuery query = new FrmDataQuery(moduleInfo.orderMaster);
            DialogResult result = query.ShowDialog();
            if (result == DialogResult.Yes)
            {
                dGridorderMaster.DataSource = query.rTable;
            }
        }
        //订单选项卡导出
        private void toolStripButton18_Click(object sender, EventArgs e)
        {
            FrmExcelExport frm = new FrmExcelExport(moduleInfo.orderMaster , dGridorderMaster, "订单");
            frm.ShowDialog();
        }

        private void toolStripButton13_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //未审核订单选项卡编辑
        private void toolStripButton16_Click(object sender, EventArgs e)
        {
            state = "编辑";
            FrmorderMasterAdd orderMasterAdd = new FrmorderMasterAdd(bindingSource2, state);
            orderMasterAdd.ShowDialog();
        }
        //未审核订单选项卡删除
        private void toolStripButton19_Click(object sender, EventArgs e)
        {
            string orderNo = dGridNocheck.Rows[dGridNocheck.CurrentRow.Index].Cells[1].Value.ToString();
            try
            {

                if (basicSql.getOrderStatus(orderNo) != "新建")
                {
                    MessageBox.Show("订单已审核，不能删除");
                }
                else
                {
                    DialogResult result = MessageBox.Show("是否删除：" + orderNo + "！", "提示信息", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {

                        bindingSource2.DataSource = orderMaster.orderMasterDel(orderNo);

                    }
                    bindingSource2.DataSource = orderMaster.getorderMasterAllByorderStatus("新建");
                    dGridNocheck.DataSource = bindingSource2;
                    DcolumnSet.colSet(moduleInfo.orderMaster, dGridNocheck);
                    toolStripStatusLabel1.Text = "数据总条数:" + dGridorderproduce.RowCount.ToString() + "条";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
        //未审核订单选项卡查询
        private void toolStripButton20_Click(object sender, EventArgs e)
        {
            FrmDataQuery query = new FrmDataQuery(moduleInfo.orderMaster);
            DialogResult result = query.ShowDialog();
            if (result == DialogResult.Yes)
            {
                dGridNocheck.DataSource = query.rTable;
            }
        }
        //未审核订单选项卡导出
        private void toolStripButton21_Click(object sender, EventArgs e)
        {
            FrmExcelExport frm = new FrmExcelExport(moduleInfo.orderMaster, dGridNocheck, "订单");
            frm.ShowDialog();
        }

        private void toolStripButton22_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //已审核订单选项卡编辑
        private void toolStripButton23_Click(object sender, EventArgs e)
        {
            state = "编辑";
            FrmorderMasterAdd orderMasterAdd = new FrmorderMasterAdd(bindingSource1, state);
            orderMasterAdd.ShowDialog();
        }
        //已审核订单选项卡查询
        private void toolStripButton25_Click(object sender, EventArgs e)
        {
            FrmDataQuery query = new FrmDataQuery(moduleInfo.orderMaster);
            DialogResult result = query.ShowDialog();
            if (result == DialogResult.Yes)
            {
                dGridorderproduce.DataSource = query.rTable;
            }
        }
        //已审核订单选项卡导出
        private void toolStripButton26_Click(object sender, EventArgs e)
        {
            FrmExcelExport frm = new FrmExcelExport(moduleInfo.orderMaster, dGridorderproduce, "订单");
            frm.ShowDialog();
        }

        private void toolStripButton27_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //数量变更选项卡导出
        private void toolStripButton29_Click(object sender, EventArgs e)
        {
            FrmExcelExport frm = new FrmExcelExport(moduleInfo.orderMaster, dGridupdate, "订单");
            frm.ShowDialog();
        }

        private void toolStripButton30_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //取消选项卡导出
        private void toolStripButton24_Click(object sender, EventArgs e)
        {
            FrmExcelExport frm = new FrmExcelExport(moduleInfo.orderMaster, dGridquxiao, "订单");
            frm.ShowDialog();
        }

        private void toolStripButton28_Click(object sender, EventArgs e)
        {
            this.Close();
        }
         //已复期选项卡导出
        private void toolStripButton31_Click(object sender, EventArgs e)
        {
             FrmExcelExport frm = new FrmExcelExport(moduleInfo.orderMaster, dGridfuqiYes, "订单");
            frm.ShowDialog();
        }

        private void toolStripButton32_Click(object sender, EventArgs e)
        {
            this .Close ();
        }
        //未复期选项卡导出
        private void toolStripButton33_Click(object sender, EventArgs e)
        {
          FrmExcelExport frm = new FrmExcelExport(moduleInfo.orderMaster, dGridfuqiNo, "订单");
            frm.ShowDialog();
        }

        private void toolStripButton34_Click(object sender, EventArgs e)
        {
        this .Close ();
        }

        private void toolStripButton35_Click(object sender, EventArgs e)
        {
            state = "新增";
            FrmorderMasterAdd orderMasterAdd = new FrmorderMasterAdd(bindingSourorderMaster, state);
            orderMasterAdd.ShowDialog();
            orderMasterAdd.Owner = this;
        }

        private void toolStripMenuItem6_Click(object sender, EventArgs e)
        {
            string orderNo = dGridorderproduce.CurrentRow.Cells["orderNo"].Value.ToString();
            //string ptype = dGridorderMaster.CurrentRow.Cells["ptype"].Value.ToString();
            Report r = new Report();
            DataSet ds = new DataSet();
            ds.Tables.Add(orderMaster.getorderproduceTableAllByptype  (orderNo, "梳织"));
          //r.Load(@"E:\东华软件项目\报表\orderproduce.frx");
          r.Load(@"\\192.168.0.27\东华软件\报表\orderproduce.frx");
            //r.Load(@"\\192.168.0.27\东华软件\报表\orderproduce.frx");

            r.RegisterData(ds);
            //r.Design();
            r.Show();
        }

        private void toolStripMenuItem7_Click(object sender, EventArgs e)
        {
            string orderNo = dGridorderproduce.CurrentRow.Cells["orderNo"].Value.ToString();
            //string ptype = dGridorderMaster.CurrentRow.Cells["ptype"].Value.ToString();
            Report r = new Report();
            DataSet ds = new DataSet();
           ds.Tables.Add(orderMaster.getorderproduceTableAllByptype(orderNo, "针织"));
            // ds.Tables.Add(orderDetail.getorderDetailByorderptype(orderNo, "针织"));
         //  r.Load(@"e:\东华软件项目\报表\orderproduce.frx");
          r.Load(@"\\192.168.0.27\东华软件\报表\orderproduce.frx");
            r.RegisterData(ds);
            //r.Design();
            r.Show();
        }

        private void toolStripMenuItem5_Click(object sender, EventArgs e)
        {
            string orderNo = dGridorderproduce.Rows[dGridorderproduce.CurrentRow.Index].Cells[1].Value.ToString();
            Frmordercheck check = new Frmordercheck(bindingSource1, orderNo);
            check.ShowDialog();
        }

        private void 查看订单ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string orderNo = dGridfuqiNo.Rows[dGridfuqiNo.CurrentRow.Index].Cells[1].Value.ToString();
            Frmordercheck check = new Frmordercheck(bSourcefuqiNo, orderNo);
            check.ShowDialog();
        }

        private void chToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string orderNo = dGridupdate.Rows[dGridupdate.CurrentRow.Index].Cells[1].Value.ToString();
            bgSourceqtyupdate.DataSource = orderMaster.getorderMasterAllByorderNo(orderNo);
            Frmordercheck check = new Frmordercheck(bgSourceqtyupdate, orderNo);
            check.ShowDialog();
        }

        private void 查看订单ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            
            string orderNo = dGridquxiao.Rows[dGridquxiao.CurrentRow.Index].Cells[1].Value.ToString();
            bgSourcequxiao.DataSource = orderMaster.getorderMasterAllByorderNo(orderNo);
            Frmordercheck check = new Frmordercheck(bgSourcequxiao, orderNo);
            check.ShowDialog();
        }

        private void toolStripButton36_Click(object sender, EventArgs e)
        {
            string orderNo = dGridNocheck.Rows[dGridNocheck.CurrentRow.Index].Cells[1].Value.ToString();
            bgSourcecheck.DataSource = orderMaster.getorderMasterAllByorderNo(orderNo);
            Frmcheck2 check = new Frmcheck2(bgSourcecheck, orderNo);
            check.ShowDialog();
            bindingSource2.DataSource = orderMaster.getorderMasterAllByorderStatus("新建");
            dGridNocheck.DataSource = bindingSource2;
            DcolumnSet.colSet(moduleInfo.orderMaster, dGridNocheck);
            toolStripStatusLabel1.Text = "数据总条数:" + dGridorderproduce.RowCount.ToString() + "条";
        }

        private void toolStripButton37_Click(object sender, EventArgs e)
        {
            string orderNo = dGridorderproduce.Rows[dGridorderproduce.CurrentRow.Index].Cells[1].Value.ToString();
            bgSourcecheck.DataSource = orderMaster.getorderMasterAllByorderNo(orderNo);
            Frmcheck2 check = new Frmcheck2(bgSourcecheck, orderNo);
            check.ShowDialog();
            bindingSource1.DataSource = orderMaster.getorderMasterAllByorderStatusNo("新建");
            dGridorderproduce.DataSource = bindingSource1;
            DcolumnSet.colSet(moduleInfo.orderMaster, dGridorderproduce);
            toolStripStatusLabel1.Text = "数据总条数:" + dGridorderproduce.RowCount.ToString() + "条";
        }

        private void toolStripButton38_Click(object sender, EventArgs e)
        {
            string orderNo = dGridorderproduce.CurrentRow.Cells["orderNo"].Value.ToString();
            Frmwritecolor wretecolor = new Frmwritecolor(orderNo,"颜色");
            DialogResult result = wretecolor.ShowDialog();
            if (result == DialogResult.Yes)
            {
                bindingSource1.DataSource = orderMaster.getorderMasterAllByorderStatusNo("新建");
                dGridorderproduce.DataSource = bindingSource1;
                DcolumnSet.colSet(moduleInfo.orderMaster, dGridorderproduce);
            }
        }

        private void button15_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter )
            {
                button15.PerformClick();
            }
        }

        private void buttonQuery_Click(object sender, EventArgs e)
        {

        }

        private void dGridorderMaster_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            //MessageBox.Show("出现错误的列" + dGridorderMaster.Columns[e.ColumnIndex].HeaderText.ToString() + "请上报系统管理员");
            e.Cancel = true;
        }

        private void dGridNocheck_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            //MessageBox.Show("出现错误的列" + dGridNocheck.Columns[e.ColumnIndex].HeaderText.ToString() + "请上报系统管理员");
            e.Cancel = true;
        }

        private void dGridorderproduce_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
           // MessageBox.Show("出现错误的列" + dGridorderproduce.Columns[e.ColumnIndex].HeaderText.ToString() + "请上报系统管理员");
            e.Cancel = true;
        }

        private void dGridupdate_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            //MessageBox.Show("出现错误的列" + dGridupdate.Columns[e.ColumnIndex].HeaderText.ToString() + "请上报系统管理员");
            e.Cancel = false;
         
        }

        private void dGridquxiao_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            //MessageBox.Show("出现错误的列" + dGridquxiao.Columns[e.ColumnIndex].HeaderText.ToString() + "请上报系统管理员");
            e.Cancel = false;

        }

        private void dGridfuqiYes_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            //MessageBox.Show("出现错误的列" + dGridfuqiYes.Columns[e.ColumnIndex].HeaderText.ToString() + "请上报系统管理员");
            e.Cancel = false;
        }

        private void dGridfuqiNo_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            //MessageBox.Show("出现错误的列" + dGridfuqiNo.Columns[e.ColumnIndex].HeaderText.ToString() + "请上报系统管理员");
            e.Cancel = false;
        }

    
        }
    }

